<?php

namespace app\common\model;

use think\Cache;
use think\Model;

/**
 * 货架管理表
 */
class Shelves extends Model
{

    public static function getList(){
        //默认全部空置
        db('shelves')->where('switch',1)->update(['ifempty'=>1]);
        $shelves_ids = db('wms_kc')->where([
            'quantity' => ['GT',0],
            'status' => 1
        ])
        ->group('shelves_id')
        ->field('shelves_id')
        ->column('shelves_id');
        if($shelves_ids){
            db('shelves')->where('id','IN',$shelves_ids)->update(['ifempty'=>0]);
        }
        
        $field = 'id,number,name,warehouse_id,type,ifnull(remark,"") remark,
ifnull(row_number,"") row_number,ifnull(column_number,"") column_number,ifnull(layers_number,"") layers_number,
ifnull(max_number,"") max_number,
ifnull(max_weight,"") max_weight,ifnull(max_volume,"") max_volume,
ifnull(`long`,0) `long`,ifnull(width,0) width,ifnull(high,0) high,
ifnull(size,"") size,ifnull(picking_ordre,"") picking_ordre,ifnull(listing_order,"") listing_order,ifempty';
        $data = self::field($field)->where([
            'switch' => 1,
            'deletetime' => null
        ])->select();
        return $data;
    }

}
